package br.inf.prismasoft.academix.entity;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Avaliacao generated by hbm2java
 */
@Entity
@Table(name = "AVALIACAO", schema = "ACADEMIX")
public class Avaliacao implements java.io.Serializable {

	private static final long serialVersionUID = -7170212497236906438L;
	private int idtAvaliacao;
	private Disciplina disciplina;
	private Turma turma;
	private String codAvaliacao;
	private Set<AvaliacaoItem> avaliacaoItems = new HashSet<AvaliacaoItem>(0);

	public Avaliacao() {
	}

	public Avaliacao(int idtAvaliacao, Disciplina disciplina, Turma turma,
			String codAvaliacao) {
		this.idtAvaliacao = idtAvaliacao;
		this.disciplina = disciplina;
		this.turma = turma;
		this.codAvaliacao = codAvaliacao;
	}

	public Avaliacao(int idtAvaliacao, Disciplina disciplina, Turma turma,
			String codAvaliacao, Set<AvaliacaoItem> avaliacaoItems) {
		this.idtAvaliacao = idtAvaliacao;
		this.disciplina = disciplina;
		this.turma = turma;
		this.codAvaliacao = codAvaliacao;
		this.avaliacaoItems = avaliacaoItems;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "idt_avaliacao", unique = true, nullable = false)
	public int getIdtAvaliacao() {
		return this.idtAvaliacao;
	}

	public void setIdtAvaliacao(int idtAvaliacao) {
		this.idtAvaliacao = idtAvaliacao;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ind_disciplina", nullable = false)
	@NotNull
	public Disciplina getDisciplina() {
		return this.disciplina;
	}

	public void setDisciplina(Disciplina disciplina) {
		this.disciplina = disciplina;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ind_turma", nullable = false)
	@NotNull
	public Turma getTurma() {
		return this.turma;
	}

	public void setTurma(Turma turma) {
		this.turma = turma;
	}

	@Column(name = "cod_avaliacao", nullable = false, length = 8)
	@NotNull
	@Length(max = 8)
	public String getCodAvaliacao() {
		return this.codAvaliacao;
	}

	public void setCodAvaliacao(String codAvaliacao) {
		this.codAvaliacao = codAvaliacao;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "avaliacao")
	public Set<AvaliacaoItem> getAvaliacaoItems() {
		return this.avaliacaoItems;
	}

	public void setAvaliacaoItems(Set<AvaliacaoItem> avaliacaoItems) {
		this.avaliacaoItems = avaliacaoItems;
	}

}
